<?php
/**
*
* @package ppkBB3cker
* @version $Id: posting_add2.php 1.000 2009-05-14 15:51:00 PPK $
* @copyright (c) 2009 PPK
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*
*/

/**
* @ignore
*/
if (!defined('IN_PHPBB'))
{
	exit;
}

if($is_cansetfree || $is_cansetreqratioupload || $is_cansetup)
{
	$curr_ftp=get_freetorr_percent($config['ppkbb_freetorr_percent'], $torrent_free);
	$max_ftp=get_freetorr_max($config['ppkbb_freetorr_percent']);
	$form_freetorr_percent='';

	foreach($user->lang['FREETORR_PERCENT'] as $ftp_k=>$ftp_v)
	{
		$ftp_select='';
		$curr_ftp==$ftp_k ? $ftp_select=' selected="selected"' : '';
		$form_freetorr_percent.='<option value="'.$max_ftp[$ftp_k].'"'.$ftp_select.'>'.$ftp_v.'</option>';
	}
	$template->assign_block_vars('addit_js', array(
			'TRACKER_ADDIT_JS'=>'
			<script type="text/javascript">
			// <![CDATA[
				function form_freetorr_select(val)
				{
					if(val <= '.$max_ftp[1].' && val > 0)
					{
						return '.$max_ftp[1].';
					}
					else if(val > '.$max_ftp[2].')
					{
						return '.$max_ftp[3].';
					}
					else if(val > '.$max_ftp[1].' && val <= '.$max_ftp[2].')
					{
						return '.$max_ftp[2].';
					}
					else
					{
						return 0;
					}
				}
			// ]]>
			</script>
			',
		)
	);
	$template->assign_vars(array(
		'FORM_FREETORR_PERCENT'=>'<select onChange="this.form.torrent_free.value=this.form.freetorr_percent.value;" name="freetorr_percent">'.$form_freetorr_percent.'</select>',
		'TORRENT_FREE_VAL'=>$torrent_free,
		'CURR_TORRENT_FREE'=>'<input onChange="this.form.freetorr_percent.value=form_freetorr_select(this.form.torrent_free.value);" type="text" name="torrent_free" size="3" maxlength="3" value="'.$torrent_free.'" />',
		'TORRENT_UP_VAL'=>$torrent_up,
		'CURR_TORRENT_UP'=>'<input type="text" name="torrent_up" size="3" maxlength="3" value="'.$torrent_up.'" />',
		'TORRENT_REQRATIO_VAL'=>$torrent_reqratio,
		'CURR_TORRENT_REQRATIO'=>'<input type="text" name="torrent_reqratio" size="5" maxlength="5" value="'.$torrent_reqratio.'" />',
		'TORRENT_REQUPLOAD_VAL'=>$torrent_requpload,
		'CURR_TORRENT_REQUPLOAD'=>'<input type="text" name="torrent_requpload" size="3" maxlength="3" value="'.$torrent_requpload.'" />',
		)
	);
}
?>
